var now = new Date();
getElementById("hour").innerText = now.getHours();
var hourProp = parseInt((now.getHours()*60 + now.getMinutes())/(24*60)*100)+"%";
getElementById("process_hour").style.width = hourProp;
getElementById("hour_txt").innerText = hourProp;

var chinaDay = now.getDay();
if (chinaDay == 0) {
    chinaDay = 7;
}
var dayProp = parseInt(((chinaDay-1)*24 + now.getHours())/(7*24)*100)+"%";
getElementById("day").innerText = chinaDay - 1;
getElementById("process_day").style.width = dayProp;
getElementById("day_txt").innerText = dayProp;

var mouthProp = parseInt((((now.getDate()-1)*24 + now.getHours())/(getMonthCountDay(now)*24))*100)+"%";
getElementById("month").innerText = now.getDate()-1;
getElementById("process_month").style.width = mouthProp;
getElementById("month_txt").innerText = mouthProp;

var totalYear = getTotalYear(now.getFullYear());
var d1 = Math.ceil((now - new Date(now.getFullYear().toString())) / (24 * 60 * 60 * 1000)) - 1;
var mouthProp = parseInt((d1/ totalYear) * 100) + "%";
getElementById("year").innerText = now.getMonth();
getElementById("process_year").style.width = mouthProp;
getElementById("year_txt").innerText = mouthProp;
getElementById("year_div").getAttributeNode("data-tips").value = now.getFullYear() + "年总共"+totalYear+"天已经过了"+d1+"还剩"+(totalYear-d1)+"天";

function getMonthCountDay(date){
    var year = date.getFullYear();
    var month = date.getMonth()+1;
    var d = new Date(year, month, 0);
    return d.getDate();
}

function getTotalYear(year){
    let leapYear = false, sum_day = 0, month_arr = [4, 6, 9, 11];
    if (year % 100 === 0) { // 年份是整百
        leapYear = year % 400 === 0
    } else {
        leapYear = year % 4 === 0
    }
    // 下面计算每个月的天数
    for (let i = 1; i < 13; i++) {
        if (i === 2) {
            sum_day += leapYear ? 29 : 28
        } else if (month_arr.includes(i)) {
            sum_day += 30
        } else {
            sum_day += 31
        }
    }
    return sum_day
}